package ru.sgu.diploma.practic.gui.dftab;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

/**
 * User: datmakin
 * Date: 16.03.11
 * Email: atmakin.dv@gmail.com
 */
public class Image extends JPanel {

    private BufferedImage bi;

    public Image(BufferedImage bi) {
        super();
        this.bi = bi;
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);       // paint background
        Graphics2D g2 = (Graphics2D) g; // we need a Graphics2D context
        AffineTransform xform = AffineTransform.getScaleInstance(0.5, 0.5);
        g2.drawImage(bi, xform, null);
        setSize(bi.getWidth() / 2, bi.getHeight() / 2);
    }
}